﻿<Window x:Class="SerialPortTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="串口测试工具" Height="412" Width="740">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Margin="5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="30*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="15*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="20*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="20*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="20*"/>
                <ColumnDefinition Width="30*"/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" VerticalAlignment="Center" Text="波特率：" Margin="0,0,5,0"/>
            <ComboBox Grid.Column="1" Name="Cmb_BaudRate" Margin="0,0,5,0" IsEditable="True">
                <ComboBoxItem>300</ComboBoxItem>
                <ComboBoxItem>600</ComboBoxItem>
                <ComboBoxItem>1200</ComboBoxItem>
                <ComboBoxItem>1800</ComboBoxItem>
                <ComboBoxItem>2400</ComboBoxItem>
                <ComboBoxItem>4800</ComboBoxItem>
                <ComboBoxItem>7200</ComboBoxItem>
                <ComboBoxItem>9600</ComboBoxItem>
                <ComboBoxItem>14400</ComboBoxItem>
                <ComboBoxItem>19200</ComboBoxItem>
                <ComboBoxItem>14400</ComboBoxItem>
                <ComboBoxItem>19200</ComboBoxItem>
                <ComboBoxItem>38400</ComboBoxItem>
                <ComboBoxItem>57600</ComboBoxItem>
                <ComboBoxItem>115200</ComboBoxItem>
                <ComboBoxItem>128000</ComboBoxItem>
            </ComboBox>
                    <TextBlock Grid.Column="2" VerticalAlignment="Center"  Text="数据位：" Margin="0,0,5,0"/>
            <ComboBox Grid.Column="3" Name="Cmb_Bit" Margin="0,0,5,0" IsEditable="True">
                <ComboBoxItem>4</ComboBoxItem>
                <ComboBoxItem>5</ComboBoxItem>
                <ComboBoxItem>6</ComboBoxItem>
                <ComboBoxItem>7</ComboBoxItem>
                <ComboBoxItem>8</ComboBoxItem>
            </ComboBox>
            <TextBlock Grid.Column="4" VerticalAlignment="Center" Text="校验方式：" Margin="0,0,5,0"/>
            <ComboBox Grid.Column="5" Name="Cmb_Check" Margin="0,0,5,0"  ItemsSource="{Binding}"/>
            <TextBlock Grid.Column="6" VerticalAlignment="Center" Text="停止位：" Margin="0,0,5,0"/>
            <ComboBox Grid.Column="7" Name="Cmb_StopBit" Margin="0,0,5,0" ItemsSource="{Binding}"/>
            <TextBlock Grid.Column="8" VerticalAlignment="Center" Text="串口号：" Margin="0,0,5,0"/>
            <ComboBox Grid.Column="9" Name="Cmb_PortNum" Margin="0,0,5,0" ItemsSource="{Binding}"/>
            <Button Grid.Column="10" Name="Btn_OpenOrClose" Margin="0,0,0,0" Content="打开串口" Click="Btn_OpenOrClose_Click" />
        </Grid>
        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="5" Grid.Row="1" Margin="5">
            <Grid Margin="5">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <DockPanel Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Height="80" LastChildFill="True">
                    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
                        <TextBlock Text="发送数据:" Margin="0,5,5,5" VerticalAlignment="Center"/>
                        <CheckBox Name="Chk_Hex" VerticalAlignment="Center" Content="使用Hex码发送"/>
                        <CheckBox Name="Chk_HalfDuplex" VerticalAlignment="Center" Content="半双工发送（不选择则是全双工模式，对于485总线控制，只能是半双工）"/>
                    </StackPanel>
                    <TextBox Margin="0,0,0,5" Name="Txt_SendData" DockPanel.Dock="Bottom"/>
                </DockPanel>
                <Button Margin="5,5,0,5" Grid.Row="0" VerticalAlignment="Bottom" Grid.Column="1" Name="Btn_Send" Width="80" Height="22" Content="发送数据" Click="Btn_Send_Click" />
                <Button Margin="5,5,0,5" Grid.Row="1" VerticalAlignment="Bottom" Grid.Column="1" Name="Btn_Clear" Width="80" Height="22" Content="清空信息" Click="Btn_Clear_Click" />
            </Grid>
        </Border>
        <RichTextBox Name="RichTxt_Data" Margin="5" Grid.Row="2"/>
    </Grid>
</Window>
